package com.huitu.whht.base.core.api.geo.stat;

import com.huitu.api.rest.AbstractApiResource;
import com.huitu.commons.PageUtils;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiResource;
import com.huitu.whht.api.core.common.annotations.SzyCoreApiService;
import com.huitu.whht.api.core.common.response.ApiResultBuilder;
import com.huitu.whht.base.core.api.geo.stat.entities.GeoStatQo;
import com.huitu.whht.base.core.api.geo.stat.service.IGeoStatCoreService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Component
@SzyCoreApiResource
@Path("geo/stat")
public class GeoStatCoreResource extends AbstractApiResource {
    private static final Logger logger = LoggerFactory.getLogger(GeoStatCoreResource.class);
    private static final String UUID = "7921e27b-4fcf-4ac3-a97c-f50b2681fc79";
    @Override
    public String getUUID() {
        return UUID;
    }
    @Autowired
    @SzyCoreApiService
    private IGeoStatCoreService geoStatCoreService;
    /**
     * @api {get} geo/stat/{stcd:\w{8}} [R]根据主键查询
     * @apiDescription 根据主键查询GEO_STAT_5T入河排污口空间信息数据
     * @apiName select by primary key
     * @apiGroup GEO_S05_0001-水文测站空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/stat/61732500
     * @apiParam {String}         stcd              【必须】水文测站代码
     * @apiSuccess {String}         stcd              水文测站代码
     * @apiSuccess {String}         stNm              入河排污口名称
     * @apiSuccess {String}         lgtd               经度
     * @apiSuccess {String}         lttd               纬度
     * @apiSuccess {String}         shape              空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": {
     * "stcd": "61732500",
     * "stNm": "金塘",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "__index": 0
     * }
     * }
     * @apiUse exceptions
     */
    @GET
    @Path("{stcd:\\w{8}}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectByPrimaryKey(@PathParam("stcd") String stcd) {
        logger.info("根据主键查询 水文测站空间信息,参数 stcd:{}", stcd);
        return Response.ok(ApiResultBuilder.create(this, geoStatCoreService.selectByPrimaryKey(stcd))).build();
    }
    /**
     * @api {post} geo/stat/list [R]根据条件查询(含空间信息)
     * @apiDescription 根据条件查询GEO_STAT_5T水文测站空间信息数据(含空间信息)
     * @apiName select by filter
     * @apiGroup GEO_S05_0001-水文测站空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/stat/list
     * @apiParam {String}         stcd               测站代码
     * @apiParam {String}         stNm               测站名称
     * @apiParam {List(String)}   stTpList           (数组)测站类别
     * @apiParam {String}         loc                所在地
     * @apiParam {List(String)}   stbkList           (数组)测站岸别
     * @apiParam {List(String)}   flowDirList        (数组)水流流向
     * @apiParam {List(String)}   datTpList          (数组)基面类型
     * @apiParam {Double}         datElevMin         (最小)基面高程
     * @apiParam {Double}         datElevMax         (最大)基面高程
     * @apiParam {Double}         modBasValMin       (最小)修正基值
     * @apiParam {Double}         modBasValMax       (最大)修正基值
     * @apiParam {List(Double)}   modParaList        (数组)修正参数
     * @apiParam {List(String)}   monTpAList         (数组)监测方式A
     * @apiParam {List(String)}   monTpBList         (数组)监测方式B
     * @apiParam {List(String)}   runCondList        (数组)运行状况
     * @apiParam {List(String)}   engManCdList       (数组)管理单位代码
     * @apiParam {String}         engManCd           管理单位代码
     * @apiParam {List(String)}   pinYinCdList       (数组)拼音码
     * @apiParam {String}         pinYinCd           拼音码
     * @apiParam {Date}           tsBgTm             (开始时间)时间戳
     * @apiParam {Date}           tsEdTm             (结束时间)时间戳
     * @apiParam {String}         nt                 备注
     * @apiSuccess {String}         stcd              水文测站代码
     * @apiSuccess {String}         stNm              入河排污口名称
     * @apiSuccess {String}         lgtd               经度
     * @apiSuccess {String}         lttd               纬度
     * @apiSuccess {String}         shape              空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "stcd": "61732500",
     * "stNm": "金塘",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * }
    ]
     * }
     * @apiSuccessExample 分页请求:
     * request header: Rang={max=50;size=50;field=TS DESC}
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     * "stcd": "61732500",
     * "stNm": "金塘",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "__index": 0
     * },
     * {
     * "stcd": "61732500",
     * "stNm": "金塘",
     * "lgtd": 114.111.251694444444,
     * "lttd": 31.8953333333333,
     * "shape": "POINT (111.251694444444 31.8953333333333)",
     * "__index": 1

     * }
     * }
     * @apiUse header_rang
     * @apiUse exceptions
     */
    @POST
    @Path("list")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectList(GeoStatQo filter){
        PageUtils.startPageFromRang();
        logger.info("根据条件查询 水文测站空间信息，参数GeoStatQo{}",filter);
        return  Response.ok(ApiResultBuilder.create(this,geoStatCoreService.selectList(filter))).build();
    }
    /**
     * @api {post} geo/stat/wfz-stat-geo [R]根据条件查询 水功能区水文测站空间信息(含空间信息)
     * @apiDescription 根据条件查询GEO_STAT_5T 水功能区水文测站空间信息(含空间信息)
     * @apiName select by filter
     * @apiGroup GEO_S05_0001-水文测站空间信息
     * @apiVersion 1.0.0
     * @apiSampleRequest geo/stat/wfz-stat-geo
     * @apiParam {String}         stcd               测站代码
     * @apiParam {String}         stNm               测站名称
     * @apiParam {List(String)}   stTpList           (数组)测站类别
     * @apiParam {String}         loc                所在地
     * @apiParam {List(String)}   stbkList           (数组)测站岸别
     * @apiParam {List(String)}   flowDirList        (数组)水流流向
     * @apiParam {List(String)}   datTpList          (数组)基面类型
     * @apiParam {Double}         datElevMin         (最小)基面高程
     * @apiParam {Double}         datElevMax         (最大)基面高程
     * @apiParam {Double}         modBasValMin       (最小)修正基值
     * @apiParam {Double}         modBasValMax       (最大)修正基值
     * @apiParam {List(Double)}   modParaList        (数组)修正参数
     * @apiParam {List(String)}   monTpAList         (数组)监测方式A
     * @apiParam {List(String)}   monTpBList         (数组)监测方式B
     * @apiParam {List(String)}   runCondList        (数组)运行状况
     * @apiParam {List(String)}   engManCdList       (数组)管理单位代码
     * @apiParam {String}         engManCd           管理单位代码
     * @apiParam {List(String)}   pinYinCdList       (数组)拼音码
     * @apiParam {String}         pinYinCd           拼音码
     * @apiParam {Date}           tsBgTm             (开始时间)时间戳
     * @apiParam {Date}           tsEdTm             (结束时间)时间戳
     * @apiParam {String}         nt                 备注
     * @apiSuccess {String}         stcd              水文测站代码
     * @apiSuccess {String}         stNm              入河排污口名称
     * @apiSuccess {String}         lgtd               经度
     * @apiSuccess {String}         lttd               纬度
     * @apiSuccess {String}         shape              空间信息
     * @apiSuccessExample 请求成功:
     * HTTP/1.1 200 OK
     * {
     * "result": [ {
     *  "stcd": "61094300",
     *  "stNm": "张金",
     *  "lgtd": 112.570083333333,
     *  "lttd": 30.1811111111111,
     *  "shape": "POINT (112.570083333333 30.1811111111111)",
     *  "__index": 0
     *         }
    ]
     * }
     * @apiSuccessExample 分页请求:
     * request header: Rang={max=50;size=50;field=TS DESC}
     * HTTP/1.1 200 OK
     * {
     * "result": [{
     *  "stcd": "61094300",
     *  "stNm": "张金",
     *  "lgtd": 112.570083333333,
     *  "lttd": 30.1811111111111,
     *  "shape": "POINT (112.570083333333 30.1811111111111)",
     *  "__index": 0
     * }
     * }
     * @apiUse header_rang
     * @apiUse exceptions
     */
    @POST
    @Path("wfz-stat-geo")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response selectWfzStatGeo(GeoStatQo filter){
        PageUtils.startPageFromRang();
        logger.info("根据条件查询 水功能区水文测站空间信息，参数GeoStatQo{}",filter);
        return  Response.ok(ApiResultBuilder.create(this,geoStatCoreService.selectWfzStatGeo(filter))).build();
    }
}
